// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#pragma once

#include <melon/range.h>

namespace kumo::pollux {
    /// Pollux metrics Registration.
    void registerPolluxMetrics();

    constexpr melon::StringPiece kMetricHiveFileHandleGenerateLatencyMs{
        "pollux.hive_file_handle_generate_latency_ms"
    };

    constexpr melon::StringPiece kMetricCacheShrinkCount{
        "pollux.cache_shrink_count"
    };

    constexpr melon::StringPiece kMetricCacheShrinkTimeMs{"pollux.cache_shrink_ms"};

    constexpr melon::StringPiece kMetricMaxSpillLevelExceededCount{
        "pollux.spill_max_level_exceeded_count"
    };

    constexpr melon::StringPiece kMetricQueryMemoryReclaimTimeMs{
        "pollux.query_memory_reclaim_time_ms"
    };

    constexpr melon::StringPiece kMetricQueryMemoryReclaimedBytes{
        "pollux.query_memory_reclaim_bytes"
    };

    constexpr melon::StringPiece kMetricQueryMemoryReclaimCount{
        "pollux.query_memory_reclaim_count"
    };

    constexpr melon::StringPiece kMetricTaskMemoryReclaimCount{
        "pollux.task_memory_reclaim_count"
    };

    constexpr melon::StringPiece kMetricTaskMemoryReclaimWaitTimeMs{
        "pollux.task_memory_reclaim_wait_ms"
    };

    constexpr melon::StringPiece kMetricTaskMemoryReclaimExecTimeMs{
        "pollux.task_memory_reclaim_exec_ms"
    };

    constexpr melon::StringPiece kMetricTaskMemoryReclaimWaitTimeoutCount{
        "pollux.task_memory_reclaim_wait_timeout_count"
    };

    constexpr melon::StringPiece kMetricOpMemoryReclaimTimeMs{
        "pollux.op_memory_reclaim_time_ms"
    };

    constexpr melon::StringPiece kMetricOpMemoryReclaimedBytes{
        "pollux.op_memory_reclaim_bytes"
    };

    constexpr melon::StringPiece kMetricOpMemoryReclaimCount{
        "pollux.op_memory_reclaim_count"
    };

    constexpr melon::StringPiece kMetricMemoryNonReclaimableCount{
        "pollux.memory_non_reclaimable_count"
    };

    constexpr melon::StringPiece kMetricMemoryPoolInitialCapacityBytes{
        "pollux.memory_pool_initial_capacity_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryPoolCapacityGrowCount{
        "pollux.memory_pool_capacity_growth_count"
    };

    constexpr melon::StringPiece kMetricMemoryPoolUsageLeakBytes{
        "pollux.memory_pool_usage_leak_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryPoolReservationLeakBytes{
        "pollux.memory_pool_reservation_leak_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryAllocatorDoubleFreeCount{
        "pollux.memory_allocator_double_free_count"
    };

    constexpr melon::StringPiece kMetricArbitratorLocalArbitrationCount{
        "pollux.arbitrator_local_arbitration_count"
    };

    constexpr melon::StringPiece kMetricArbitratorGlobalArbitrationCount{
        "pollux.arbitrator_global_arbitration_count"
    };

    constexpr melon::StringPiece
    kMetricArbitratorGlobalArbitrationNumReclaimVictims{
        "pollux.arbitrator_global_arbitration_num_reclaim_victims"
    };

    constexpr melon::StringPiece
    kMetricArbitratorGlobalArbitrationFailedVictimCount{
        "pollux.arbitrator_global_arbitration_failed_victim_count"
    };

    constexpr melon::StringPiece kMetricArbitratorGlobalArbitrationBytes{
        "pollux.arbitrator_global_arbitration_bytes"
    };

    constexpr melon::StringPiece kMetricArbitratorGlobalArbitrationTimeMs{
        "pollux.arbitrator_global_arbitration_time_ms"
    };

    constexpr melon::StringPiece kMetricArbitratorGlobalArbitrationWaitCount{
        "pollux.arbitrator_global_arbitration_wait_count"
    };

    constexpr melon::StringPiece kMetricArbitratorGlobalArbitrationWaitTimeMs{
        "pollux.arbitrator_global_arbitration_wait_time_ms"
    };

    constexpr melon::StringPiece kMetricArbitratorAbortedCount{
        "pollux.arbitrator_aborted_count"
    };

    constexpr melon::StringPiece kMetricArbitratorFailuresCount{
        "pollux.arbitrator_failures_count"
    };

    constexpr melon::StringPiece kMetricArbitratorOpExecTimeMs{
        "pollux.arbitrator_op_exec_time_ms"
    };

    constexpr melon::StringPiece kMetricArbitratorFreeCapacityBytes{
        "pollux.arbitrator_free_capacity_bytes"
    };

    constexpr melon::StringPiece kMetricArbitratorFreeReservedCapacityBytes{
        "pollux.arbitrator_free_reserved_capacity_bytes"
    };

    constexpr melon::StringPiece kMetricDriverYieldCount{
        "pollux.driver_yield_count"
    };

    constexpr melon::StringPiece kMetricDriverQueueTimeMs{
        "pollux.driver_queue_time_ms"
    };

    constexpr melon::StringPiece kMetricDriverExecTimeMs{
        "pollux.driver_exec_time_ms"
    };

    constexpr melon::StringPiece kMetricSpilledInputBytes{
        "pollux.spill_input_bytes"
    };

    constexpr melon::StringPiece kMetricSpilledBytes{"pollux.spill_bytes"};

    constexpr melon::StringPiece kMetricSpilledRowsCount{"pollux.spill_rows_count"};

    constexpr melon::StringPiece kMetricSpilledFilesCount{
        "pollux.spill_files_count"
    };

    constexpr melon::StringPiece kMetricSpillFillTimeMs{"pollux.spill_fill_time_ms"};

    constexpr melon::StringPiece kMetricSpillSortTimeMs{"pollux.spill_sort_time_ms"};

    constexpr melon::StringPiece kMetricSpillExtractVectorTimeMs{
        "pollux.spill_extract_vector_time_ms"
    };

    constexpr melon::StringPiece kMetricSpillSerializationTimeMs{
        "pollux.spill_serialization_time_ms"
    };

    constexpr melon::StringPiece kMetricSpillWritesCount{
        "pollux.spill_writes_count"
    };

    constexpr melon::StringPiece kMetricSpillFlushTimeMs{
        "pollux.spill_flush_time_ms"
    };

    constexpr melon::StringPiece kMetricSpillWriteTimeMs{
        "pollux.spill_write_time_ms"
    };

    constexpr melon::StringPiece kMetricSpillMemoryBytes{
        "pollux.spill_memory_bytes"
    };

    constexpr melon::StringPiece kMetricSpillPeakMemoryBytes{
        "pollux.spill_peak_memory_bytes"
    };

    constexpr melon::StringPiece kMetricFileWriterEarlyFlushedRawBytes{
        "pollux.file_writer_early_flushed_raw_bytes"
    };

    constexpr melon::StringPiece kMetricHiveSortWriterFinishTimeMs{
        "pollux.hive_sort_writer_finish_time_ms"
    };

    constexpr melon::StringPiece kMetricArbitratorRequestsCount{
        "pollux.arbitrator_requests_count"
    };

    constexpr melon::StringPiece kMetricMappedMemoryBytes{
        "pollux.memory_allocator_mapped_bytes"
    };

    constexpr melon::StringPiece kMetricAllocatedMemoryBytes{
        "pollux.memory_allocator_alloc_bytes"
    };

    constexpr melon::StringPiece kMetricMmapExternalMappedBytes{
        "pollux.mmap_allocator_external_mapped_bytes"
    };

    constexpr melon::StringPiece kMetricMmapDelegatedAllocBytes{
        "pollux.mmap_allocator_delegated_alloc_bytes"
    };

    constexpr melon::StringPiece kMetricCacheMaxAgeSecs{"pollux.cache_max_age_secs"};

    constexpr melon::StringPiece kMetricMemoryCacheNumEntries{
        "pollux.memory_cache_num_entries"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumEmptyEntries{
        "pollux.memory_cache_num_empty_entries"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumSharedEntries{
        "pollux.memory_cache_num_shared_entries"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumExclusiveEntries{
        "pollux.memory_cache_num_exclusive_entries"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumPrefetchedEntries{
        "pollux.memory_cache_num_prefetched_entries"
    };

    constexpr melon::StringPiece kMetricMemoryCacheTotalTinyBytes{
        "pollux.memory_cache_total_tiny_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryCacheTotalLargeBytes{
        "pollux.memory_cache_total_large_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryCacheTotalTinyPaddingBytes{
        "pollux.memory_cache_total_tiny_padding_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryCacheTotalLargePaddingBytes{
        "pollux.memory_cache_total_large_padding_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryCacheTotalPrefetchBytes{
        "pollux.memory_cache_total_prefetched_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryCacheSumEvictScore{
        "pollux.memory_cache_sum_evict_score"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumHits{
        "pollux.memory_cache_num_hits"
    };

    constexpr melon::StringPiece kMetricMemoryCacheHitBytes{
        "pollux.memory_cache_hit_bytes"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumNew{
        "pollux.memory_cache_num_new"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumEvicts{
        "pollux.memory_cache_num_evicts"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumSavableEvicts{
        "pollux.memory_cache_num_savable_evicts"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumEvictChecks{
        "pollux.memory_cache_num_evict_checks"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumWaitExclusive{
        "pollux.memory_cache_num_wait_exclusive"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumAllocClocks{
        "pollux.memory_cache_num_alloc_clocks"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumAgedOutEntries{
        "pollux.memory_cache_num_aged_out_entries"
    };

    constexpr melon::StringPiece kMetricMemoryCacheNumStaleEntries{
        "pollux.memory_cache_num_stale_entries"
    };

    constexpr melon::StringPiece kMetricSsdCacheCachedRegions{
        "pollux.ssd_cache_cached_regions"
    };

    constexpr melon::StringPiece kMetricSsdCacheCachedEntries{
        "pollux.ssd_cache_cached_entries"
    };

    constexpr melon::StringPiece kMetricSsdCacheCachedBytes{
        "pollux.ssd_cache_cached_bytes"
    };

    constexpr melon::StringPiece kMetricSsdCacheReadEntries{
        "pollux.ssd_cache_read_entries"
    };

    constexpr melon::StringPiece kMetricSsdCacheReadBytes{
        "pollux.ssd_cache_read_bytes"
    };

    constexpr melon::StringPiece kMetricSsdCacheWrittenEntries{
        "pollux.ssd_cache_written_entries"
    };

    constexpr melon::StringPiece kMetricSsdCacheWrittenBytes{
        "pollux.ssd_cache_written_bytes"
    };

    constexpr melon::StringPiece kMetricSsdCacheAgedOutEntries{
        "pollux.ssd_cache_aged_out_entries"
    };

    constexpr melon::StringPiece kMetricSsdCacheAgedOutRegions{
        "pollux.ssd_cache_aged_out_regions"
    };

    constexpr melon::StringPiece kMetricSsdCacheOpenSsdErrors{
        "pollux.ssd_cache_open_ssd_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheOpenCheckpointErrors{
        "pollux.ssd_cache_open_checkpoint_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheOpenLogErrors{
        "pollux.ssd_cache_open_log_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheMetaFileDeleteErrors{
        "pollux.ssd_cache_delete_meta_file_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheGrowFileErrors{
        "pollux.ssd_cache_grow_file_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheWriteSsdErrors{
        "pollux.ssd_cache_write_ssd_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheWriteSsdDropped{
        "pollux.ssd_cache_write_ssd_dropped"
    };

    constexpr melon::StringPiece kMetricSsdCacheWriteCheckpointErrors{
        "pollux.ssd_cache_write_checkpoint_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheReadCorruptions{
        "pollux.ssd_cache_read_corruptions"
    };

    constexpr melon::StringPiece kMetricSsdCacheReadSsdErrors{
        "pollux.ssd_cache_read_ssd_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheReadCheckpointErrors{
        "pollux.ssd_cache_read_checkpoint_errors"
    };

    constexpr melon::StringPiece kMetricSsdCacheReadWithoutChecksum{
        "pollux.ssd_cache_read_without_checksum"
    };

    constexpr melon::StringPiece kMetricSsdCacheCheckpointsRead{
        "pollux.ssd_cache_checkpoints_read"
    };

    constexpr melon::StringPiece kMetricSsdCacheCheckpointsWritten{
        "pollux.ssd_cache_checkpoints_written"
    };

    constexpr melon::StringPiece kMetricSsdCacheRegionsEvicted{
        "pollux.ssd_cache_regions_evicted"
    };

    constexpr melon::StringPiece kMetricSsdCacheRecoveredEntries{
        "pollux.ssd_cache_recovered_entries"
    };

    constexpr melon::StringPiece kMetricExchangeTransactionCreateDelay{
        "pollux.exchange.transaction_create_delay_ms"
    };

    constexpr melon::StringPiece kMetricExchangeDataTimeMs{
        "pollux.exchange_data_time_ms"
    };

    constexpr melon::StringPiece kMetricExchangeDataBytes{
        "pollux.exchange_data_bytes"
    };

    constexpr melon::StringPiece kMetricExchangeDataSize{
        "pollux.exchange_data_size"
    };

    constexpr melon::StringPiece kMetricExchangeDataCount{
        "pollux.exchange_data_count"
    };

    constexpr melon::StringPiece kMetricExchangeDataSizeTimeMs{
        "pollux.exchange_data_size_time_ms"
    };

    constexpr melon::StringPiece kMetricExchangeDataSizeCount{
        "pollux.exchange_data_size_count"
    };

    constexpr melon::StringPiece kMetricStorageThrottledDurationMs{
        "pollux.storage_throttled_duration_ms"
    };

    constexpr melon::StringPiece kMetricStorageLocalThrottled{
        "pollux.storage_local_throttled_count"
    };

    constexpr melon::StringPiece kMetricStorageGlobalThrottled{
        "pollux.storage_global_throttled_count"
    };

    constexpr melon::StringPiece kMetricStorageNetworkThrottled{
        "pollux.storage_network_throttled_count"
    };

    constexpr melon::StringPiece kMetricIndexLookupResultRawBytes{
        "pollux.index_lookup_result_raw_bytes"
    };

    constexpr melon::StringPiece kMetricIndexLookupResultBytes{
        "pollux.index_lookup_result_bytes"
    };

    constexpr melon::StringPiece kMetricIndexLookupTimeMs{
        "pollux.index_lookup_time_ms"
    };

    constexpr melon::StringPiece kMetricIndexLookupWaitTimeMs{
        "pollux.index_lookup_wait_time_ms"
    };

    constexpr melon::StringPiece kMetricIndexLookupBlockedWaitTimeMs{
        "pollux.index_lookup_blocked_wait_time_ms"
    };

    constexpr melon::StringPiece kMetricTableScanBatchProcessTimeMs{
        "pollux.table_scan_batch_process_time_ms"
    };

    constexpr melon::StringPiece kMetricTaskBatchProcessTimeMs{
        "pollux.task_batch_process_time_ms"
    };
} // namespace kumo::pollux
